package cn.Mmovie.servlet;

import cn.Mmovie.bean.Auditorium;
import cn.Mmovie.bean.Cinema;
import cn.Mmovie.bean.Movie;
import cn.Mmovie.service.AuditoriumService;
import cn.Mmovie.service.CinemaService;
import cn.Mmovie.service.MovieService;
import cn.Mmovie.service.impl.AuditoriumServiceImpl;
import cn.Mmovie.service.impl.CinemaServiceImpl;
import cn.Mmovie.service.impl.MovieServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "AdminAddScheduleServlet", value = "/admin/add_schedule")
public class AdminAddScheduleServlet extends HttpServlet {
    private MovieService movieService=new MovieServiceImpl();
    private AuditoriumService auditoriumService=new AuditoriumServiceImpl();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Movie> movies=movieService.queryAllMovies();
        List<Auditorium> auditoriums=auditoriumService.queryAllAuditorium();
        request.setAttribute("movies", movies);
        request.setAttribute("auditoriums",auditoriums);
        request.getRequestDispatcher("/WEB-INF/page/main/schedule_add.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
